﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class tbMatHang
    {
        private string mamh;

        public string Mamh
        {
            get { return mamh; }
            set { mamh = value; }
        }
        private string tenmh;

        public string Tenmh
        {
            get { return tenmh; }
            set { tenmh = value; }
        }
        private string hinh;

        public string Hinh
        {
            get { return hinh; }
            set { hinh = value; }
        }
        private double giaban;

        public double Giaban
        {
            get { return giaban; }
            set { giaban = value; }
        }
        private string nhasx;

        public string Nhasx
        {
            get { return nhasx; }
            set { nhasx = value; }
        }
        private string mota;

        public string Mota
        {
            get { return mota; }
            set { mota = value; }
        }
        private string malh;

        public string Malh
        {
            get { return malh; }
            set { malh = value; }
        }

        DBAccess db=new DBAccess();
        public DataTable dalHTDSMatHang()
        {
            string query = "select * from MatHang";
            SqlParameter[] param = new SqlParameter[0];
            return db.GetDataTable(query, CommandType.Text, param);
        }
        public DataTable dalTHDSMatHang()
        {
            string query = "HienThiMH";
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@MaLH", Malh);
            return db.GetDataTable(query, CommandType.StoredProcedure, param);
        }
        public DataTable dalDSMH_MaMH()
        {
            string query = "HienThiMH_MaMH";
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@MaMH", Mamh);
            return db.GetDataTable(query, CommandType.StoredProcedure, param);
        }
        public bool dalThemMH()
        {
            bool res = false;
            string query = "ThemMH";
            SqlParameter[] param = new SqlParameter[6];
            param[0] = new SqlParameter("@TenMH", Tenmh);
            param[1] = new SqlParameter("@Hinh", Hinh);
            param[2] = new SqlParameter("@GiaBan", Giaban);
            param[3] = new SqlParameter("@NhaSX", Nhasx);
            param[4] = new SqlParameter("@MoTa", Mota);
            param[5] = new SqlParameter("@MaLH", Malh);
            res = db.DoExcecute(query, CommandType.StoredProcedure, param);
            return res;
        }
        public bool dalSuaMH()
        {
            bool res = false;
            string query = "SuaMH";
            SqlParameter[] param = new SqlParameter[6];
            param[0] = new SqlParameter("@TenMH", Tenmh);
            param[1] = new SqlParameter("@Hinh", Hinh);
            param[2] = new SqlParameter("@GiaBan", Giaban);
            param[3] = new SqlParameter("@NhaSX", Nhasx);
            param[4] = new SqlParameter("@MoTa", Mota);
            param[5] = new SqlParameter("@MaMH", Mamh);
            res = db.DoExcecute(query, CommandType.StoredProcedure, param);
            return res;
        }
        public bool dalXoaMH()
        {
            bool res = false;
            string query = "XoaMH";
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@MaMH", Mamh);
            res = db.DoExcecute(query, CommandType.StoredProcedure, param);
            return res;
        }

    }
}
